package com.atguigu.gmall.all.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.item.ItemFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;


import java.util.Map;

@Controller
public class ItemController {
    @Autowired
    private ItemFeignClient itemFeignClient;


    @GetMapping("{skuId}.html")
    public String skuItem(@PathVariable Long skuId, Model model){
        Result<Map> result = itemFeignClient.skuItem(skuId);

        model.addAllAttributes(result.getData());
        //  返回商品详情的视图名称： Thymeleaf 默认返回的视图名称在tempplates 默认的后缀名 .html
        return "item/item";
    }



}
